home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performAppendDiskCache.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.8 KB  |  398 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  4 April 1997
  22. //
  23. //  Description:
  24. //      This is a helper script to perform the "diskCache -append" command
  25. //        using the corresponding option box values.
  26. //
  27.  
  28. //
  29. //  Procedure Name:
  30. //      setOptionVars
  31. //
  32. //  Description:
  33. //        Initialize the option values.
  34. //
  35. //  Input Arguments:
  36. //        Whether to set the options to default values.
  37. //
  38. //  Return Value:
  39. //      None.
  40. //
  41. proc setOptionVars(int $forceFactorySettings)
  42. {
  43.     //    Time range
  44.     //
  45.     if($forceFactorySettings || !`optionVar -exists appendDiskCacheTimeRange`)
  46.     {
  47.         optionVar -intValue appendDiskCacheTimeRange 2;
  48.     }
  49.  
  50.     //    startTime
  51.     //
  52.     if ($forceFactorySettings || !`optionVar -exists appendDiskCacheStartTime`)
  53.     {
  54.         optionVar -floatValue appendDiskCacheStartTime 1.0;
  55.     }
  56.  
  57.     //    endTime
  58.     //
  59.     if ($forceFactorySettings || !`optionVar -exists appendDiskCacheEndTime`) {
  60.         optionVar -floatValue appendDiskCacheEndTime 10.0;
  61.     }
  62.  
  63.     //    sampling mode
  64.     //
  65.     if ($forceFactorySettings || !`optionVar -exists appendDiskCacheSampling`)
  66.     {
  67.         optionVar -intValue  appendDiskCacheSampling 1;
  68.     }
  69.  
  70.     //    sampling rate
  71.     //
  72.     if( $forceFactorySettings 
  73.     ||! `optionVar -exists appendDiskCacheSamplingRate` ) 
  74.     {
  75.         optionVar -intValue appendDiskCacheSamplingRate 1;
  76.     }
  77. }
  78.  
  79.  
  80. //
  81. //  Procedure Name:
  82. //      appendDiskCacheEnabling
  83. //
  84. //  Description:
  85. //        Set the enable state of start and end time fields.
  86. //
  87. //  Input Arguments:
  88. //      parent - Top level parent layout of the option box UI.
  89. //               Required so that object names of the fields can be 
  90. //               successfully resolved.
  91. //
  92. //        state  - Enable state of the fields.
  93. //
  94. //  Return Value:
  95. //      None.
  96. //
  97. global proc appendDiskCacheEnabling()
  98. {
  99.     int $startEnd = ( `radioButtonGrp -q -sl appendDiskCacheTimeRange4` == 1 );
  100.     floatFieldGrp -edit -enable $startEnd appendDiskCacheStartEndTime;
  101. }
  102.  
  103. //
  104. //  Procedure Name:
  105. //      appendDiskCacheSetup
  106. //
  107. //  Description:
  108. //        Update the state of the option box UI to reflect the option values.
  109. //
  110. //  Input Arguments:
  111. //      parent               - Top level parent layout of the option box UI.
  112. //                             Required so that UI object names can be 
  113. //                             successfully resolved.
  114. //
  115. //        forceFactorySettings - Whether the option values should be set to
  116. //                             default values.
  117. //
  118. //  Return Value:
  119. //      None.
  120. //
  121. global proc appendDiskCacheSetup(string $parent, int $forceFactorySettings)
  122. {
  123.     //    Retrieve the option settings
  124.     //
  125.     setOptionVars($forceFactorySettings);
  126.  
  127.     setParent $parent;
  128.  
  129.     //    Range start
  130.     //
  131.     int $rangeStart = `optionVar -query appendDiskCacheTimeRange`;
  132.     eval( "radioButtonGrp -e -select 1 appendDiskCacheTimeRange"+$rangeStart);
  133.  
  134.     //    Start/End
  135.     //
  136.     float $startTime = `optionVar -query appendDiskCacheStartTime`;
  137.     float $endTime = `optionVar -query appendDiskCacheEndTime`;
  138.     floatFieldGrp -edit 
  139.         -value1 $startTime 
  140.         -value2 $endTime 
  141.         appendDiskCacheStartEndTime;
  142.  
  143.     //    -increment
  144.     //
  145.     int $sampling = `optionVar -q appendDiskCacheSampling` ;
  146.     radioButtonGrp -edit -sl $sampling appendDiskCacheSampling;
  147.  
  148.     int $samplingRate = `optionVar -q appendDiskCacheSamplingRate` ;
  149.     intSliderGrp -edit -v $samplingRate appendDiskCacheSamplingRate;
  150.  
  151.     appendDiskCacheEnabling();
  152. }
  153.  
  154. //
  155. //  Procedure Name:
  156. //      appendDiskCacheCallback
  157. //
  158. //  Description:
  159. //        Update the option values with the current state of the option box UI.
  160. //
  161. //  Input Arguments:
  162. //      parent - Top level parent layout of the option box UI.  Required so
  163. //               that UI object names can be successfully resolved.
  164. //
  165. //        doIt   - Whether the command should execute.
  166. //
  167. //  Return Value:
  168. //      None.
  169. //
  170. global proc appendDiskCacheCallback(string $parent, int $doIt)
  171. {
  172.     setParent $parent;
  173.  
  174.     //    start/end range
  175.     //
  176.     int $timeRangeMode = 2;
  177.  
  178.     if( `radioButtonGrp -q -sl appendDiskCacheTimeRange1` ) {
  179.         $timeRangeMode = 1;
  180.     } else if( `radioButtonGrp -q -sl appendDiskCacheTimeRange2` ) {
  181.         $timeRangeMode = 2;
  182.     } else if( `radioButtonGrp -q -sl appendDiskCacheTimeRange3` ) {
  183.         $timeRangeMode = 3;
  184.     } else if( `radioButtonGrp -q -sl appendDiskCacheTimeRange4` ) {
  185.         $timeRangeMode = 4;
  186.     }
  187.  
  188.     optionVar -intValue appendDiskCacheTimeRange $timeRangeMode;
  189.  
  190.     //    start/end Time
  191.     //
  192.     optionVar -floatValue appendDiskCacheStartTime
  193.         `floatFieldGrp -query -value1 appendDiskCacheStartEndTime`;
  194.     optionVar -floatValue appendDiskCacheEndTime
  195.         `floatFieldGrp -query -value2 appendDiskCacheStartEndTime`;
  196.  
  197.     //    sampling mode
  198.     //
  199.     optionVar -intValue appendDiskCacheSampling
  200.         `radioButtonGrp -query -sl appendDiskCacheSampling`;
  201.  
  202.     // sampling rate
  203.     //
  204.     optionVar -intValue appendDiskCacheSamplingRate
  205.         `intSliderGrp -query -v appendDiskCacheSamplingRate`;
  206.  
  207.     if( $doIt ) {
  208.         performAppendDiskCache 0; 
  209.     }
  210. }
  211.  
  212. //
  213. //  Procedure Name:
  214. //      appendDiskCacheOptions
  215. //
  216. //  Description:
  217. //        Construct the option box UI.  Involves accessing the standard option
  218. //        box and customizing the UI accordingly.
  219. //
  220. //  Input Arguments:
  221. //      None.
  222. //
  223. //  Return Value:
  224. //      None.
  225. //
  226. proc appendDiskCacheOptions()
  227. {
  228.     //    Name of the command for this option box.
  229.     //
  230.     string $commandName = "appendDiskCache";
  231.  
  232.     //    Build the option box actions.
  233.     //
  234.     string $callback = ($commandName + "Callback");
  235.     string $setup = ($commandName + "Setup");
  236.  
  237.     string $layout = getOptionBox();
  238.     setParent $layout;
  239.     
  240.     setUITemplate -pushTemplate DefaultTemplate;
  241.     tabLayout -tv false -scr true;
  242.     
  243.     string $parent = `columnLayout -adjustableColumn 1`;
  244.     
  245.     radioButtonGrp 
  246.         -label "Append Time Range" -nrb 1
  247.         -l1 "Current Time"
  248.         -cc "appendDiskCacheEnabling"
  249.         appendDiskCacheTimeRange1;
  250.  
  251.     radioButtonGrp 
  252.         -label "" -nrb 1
  253.         -scl appendDiskCacheTimeRange1
  254.         -l1 "Current Time to Time Slider End"
  255.         -cc "appendDiskCacheEnabling"
  256.         appendDiskCacheTimeRange2;
  257.  
  258.     radioButtonGrp 
  259.         -label "" -nrb 1
  260.         -scl appendDiskCacheTimeRange1
  261.         -l1 "Time Slider"
  262.         -cc "appendDiskCacheEnabling"
  263.         appendDiskCacheTimeRange3;
  264.  
  265.     radioButtonGrp 
  266.         -label "" -nrb 1
  267.         -scl appendDiskCacheTimeRange1
  268.         -l1 "Start/End"
  269.         -cc "appendDiskCacheEnabling"
  270.         appendDiskCacheTimeRange4;
  271.     
  272.     floatFieldGrp -nf 2 -label "Start/End" appendDiskCacheStartEndTime;
  273.     
  274.     separator -h 5 -style "none";
  275.     
  276.     radioButtonGrp -nrb 2 -l "Sampling" -l1 "Over" -l2 "Under" 
  277.         appendDiskCacheSampling;
  278.  
  279.     intSliderGrp -l "Rate" -min 1 -max 5 -fmn 1 -fmx 100 -value 1
  280.         appendDiskCacheSamplingRate;
  281.  
  282.     setUITemplate -popTemplate;
  283.  
  284.     //    'Apply' button.
  285.     //
  286.     string $applyBtn = getOptionBoxApplyBtn();
  287.     button -edit
  288.         -label "Append"
  289.         -command ($callback + " " + $parent + " " + 1)
  290.         $applyBtn;
  291.  
  292.     //    'Save' button.
  293.     //
  294.     string $saveBtn = getOptionBoxSaveBtn();
  295.     button -edit 
  296.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  297.         $saveBtn;
  298.  
  299.     //    'Reset' button.
  300.     //
  301.     string $resetBtn = getOptionBoxResetBtn();
  302.     button -edit 
  303.         -command ($setup + " " + $parent + " " + 1)
  304.         $resetBtn;
  305.  
  306.     //    Set the option box title.
  307.     //
  308.     setOptionBoxTitle("Append to Disk Cache Options");
  309.     setOptionBoxCommandName($commandName);
  310.     setOptionBoxHelpTag( "AppendToFluidsCache" );
  311.  
  312.     //    Set the current values of the option box.
  313.     //
  314.     eval( $setup + " " + $parent + " " + 0 );    
  315.     
  316.     //    Show the option box.
  317.     //
  318.     showOptionBox();
  319. }
  320.  
  321. //
  322. //  Procedure Name:
  323. //      assembleCmd
  324. //
  325. //  Description:
  326. //        Construct the command that will apply the option box values.
  327. //
  328. //  Input Arguments:
  329. //      None.
  330. //
  331. //  Return Value:
  332. //      None.
  333. //
  334. proc string assembleCmd()
  335. {
  336.     setOptionVars(false);
  337.  
  338.     string $cmd = "doAppendDiskCache 1 { " +
  339.         "\"" + `optionVar -query appendDiskCacheTimeRange` + "\"" + 
  340.         ",\"" + `optionVar -query appendDiskCacheStartTime` + "\"" +
  341.         ",\"" + `optionVar -query appendDiskCacheEndTime` + "\"" +
  342.         ",\"" + `optionVar -query appendDiskCacheSampling` + "\"" +
  343.         ",\"" + `optionVar -query appendDiskCacheSamplingRate` + "\"" +
  344.         " };";
  345.  
  346.     return $cmd;
  347. }
  348.  
  349. //
  350. //  Procedure Name:
  351. //      performAppendDiskCache
  352. //
  353. //  Description:
  354. //        Perform the command using the corresponding 
  355. //        option values.  This procedure will also show the option box
  356. //        window if necessary as well as construct the command string
  357. //        that will invoke the command with the current 
  358. //        option box values.
  359. //
  360. //  Input Arguments:
  361. //      0 - Execute the command.
  362. //      1 - Show the option box dialog.
  363. //      2 - Return the command.
  364. //
  365. //  Return Value:
  366. //      None.
  367. //
  368. global proc string performAppendDiskCache(int $action)
  369. {
  370.     string $cmd = "";
  371.  
  372.     switch ($action) {
  373.  
  374.         //    Execute the command from option settings.
  375.         //
  376.         case 0:
  377.             setOptionVars(false);
  378.             $cmd = `assembleCmd`;
  379.             eval($cmd);
  380.             break;
  381.  
  382.         //    Show the option box.
  383.         //
  384.         case 1:
  385.             appendDiskCacheOptions();
  386.             break;
  387.  
  388.         //    Return the command string.
  389.         //
  390.         case 2:
  391.             setOptionVars (false);
  392.             $cmd = `assembleCmd`;
  393.             break;
  394.     }
  395.     return $cmd;
  396. }
  397.  
  398.